package cn.cutie.clot.mq.client;

import cn.cutie.clot.mq.model.ClotMessage;
import lombok.SneakyThrows;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @Description:
 * @Author: Cutie
 * @CreateDate: 2024/6/27 12:28
 * @Version: 0.0.1
 */
public class ClotMq {
//    private String topic;
//    private LinkedBlockingQueue<ClotMessage> queue = new LinkedBlockingQueue<>();
//
//    private List<ClotListener> listeners = new ArrayList<>();
//
//    public ClotMq(String topic) {
//        this.topic = topic;
//    }
//
//    public boolean send(ClotMessage message) {
//        boolean offered = queue.offer(message);
//        listeners.forEach(listener -> listener.onMessage(message));
//        return offered;
//    }
//
//    // 拉模式
//    // 运行时再抛出异常
//    @SneakyThrows
//    public <T> ClotMessage<T> poll(long timeout) {
//        return queue.poll(timeout, TimeUnit.MILLISECONDS);
//    }
//
//    public <T> void addListener(ClotListener<T> listener) {
//        listeners.add(listener);
//    }
}
